#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__author__ = "Administrator"
__name__="myThread"
__date__="2016/9/19"
__time__="14:10"
"""
'''
把子类单独放在一个模块中，并加上一个getResult()函数用以存放函数的运行结果,使得Thread的子类更为通用（能同时适应有输出和没有输出的函数）
'''
import threading
from time import time,ctime

class MyThread(threading.Thread):
    def __init__(self,func,args,name = ''):
        super(MyThread,self).__init__()
        self.name = name
        self.func = func
        self.args = args
    def getResult(self):
        return self.res

    def run(self):
        print 'starting',self.name,'at:',ctime()
        self.res = apply(self.func,self.args)
        print self.name,'finished at:',ctime()

